<?php

	/**
	 * @see Bike_Js_Ext_Component
	 */
	require_once 'Bike/Js/Ext/Component.php';

	
	class Bike_Js_Ext_LoadMask extends Bike_Js_Ext_Component
	{
		static protected $_partOffset = 1;

		protected $_part = 'LoadMask';

		protected function initDefaultSettings()
		{
			parent::initDefaultSettings();
		
			$this->setSettings(array(
				'msg' => $this->translate('Loading...'),
				'autoShow' => true,
				'toFrontOnShow' => true,
				'bringParentToFront' => true,
				//'floating' => true,
				//'zIndex' => 999999999,
				//'focusOnToFront' => true,
			));
		}

		protected function _makeOptions(array $Args=null)
		{
			$options = array();
			$argsCount = sizeof($Args);
			if($argsCount)
			{
				if($argsCount == 1 && is_array($Args[0]))
				{
					$options = $Args[0];
				}
				elseif($argsCount == 1)
				{					$options['renderTo'] = $Args[0];
				}
				elseif($argsCount >= 2)
				{
					$options['renderTo'] = $Args[0];
					$options['msg'] = $Args[1];
				}
			}
			return $options;
		}

		public function getOmitSettings()
		{
			return array_merge(parent::getOmitSettings(), array('renderTo'));
		}

		protected function getArgs()
		{
			$renderTo = ($this->renderTo) ? $this->renderTo : $this->js()->Ext->getBody();
			return array_merge(array($this->_prepareValue($renderTo)), parent::getArgs());
		}
	}
